package com.corpgovernment.organization.mapper;

import com.corpgovernment.api.organization.model.bookingrelation.UidOrgIdEntry;
import com.corpgovernment.organization.entity.db.MbBookingRelation;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import tk.mybatis.mapper.common.IdsMapper;
import tk.mybatis.mapper.common.MySqlMapper;

import java.util.List;
import java.util.Set;

@Repository
@Mapper
public interface BookingRelationMapper extends tk.mybatis.mapper.common.Mapper<MbBookingRelation>,
    MySqlMapper<MbBookingRelation>, IdsMapper<MbBookingRelation> {

    List<String> selectUidBookingAgent(@Param("parentOrgId") String parentOrgId,
                                       @Param("childOrgIdList") List<String> childOrgIdList,
                                       @Param("havingCount") int havingCount);

    List<MbBookingRelation> pageQuery(@Param("name") String name, @Param("orgIdList") List<String> orgIds);

    List<MbBookingRelation> selectBookingRange(@Param("uidOrgIdList") List<UidOrgIdEntry> uidOrgIdList);

    List<MbBookingRelation> selectBookUidList(@Param("uid") String uid, @Param("orgId") String orgId);

    /**
     * 按查询代订范围被代订人组织id
     */
    Set<String> listBookRangeBookOrgId(@Param("uid") String uid, @Param("orgId") String orgId);

    int batchInsert(@Param("list") List<MbBookingRelation> list);

    List<MbBookingRelation> selectAllByUid(@Param("uidList")List<String> uidList);
    List<String> distinctUid(@Param("parentOrgId") String parentOrgId);
}
